import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseInterceptors, UseGuards, Req } from '@nestjs/common';
import { PlanService } from './plan.service';
import {GetPlanDto, CreatePlanDto, UpdatePlanDto } from './dto';
import { Plan } from '@prisma/client';
import { TransformDateInterceptor } from '../interceptors/transform-date.interceptor';
import { UserId } from '../decorators/user.decorator';


@UseInterceptors(TransformDateInterceptor)
@Controller('plan')
export class PlanController {
  constructor(private readonly planService: PlanService) {}

  @Post()
  create(@Body() createPlanDto: CreatePlanDto, @UserId() userId: number) {
    return this.planService.create(createPlanDto,userId);
  }

  @Get()
   findAll(@Query() query: GetPlanDto, @UserId() userId: number): Promise<Plan[]> {
    return this.planService.findAll(query, userId);
  }
  
  @Post('del')
  remove(@Body() data: { id: number }) {
    return this.planService.remove(data.id);
  }
 }
